package com.ruoyi.web.controller.websocket;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.teaching.domain.WebSocketUserDialogue;
import com.ruoyi.teaching.service.WebSocketUserDialogueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 李志鑫
 * @since 2024-08-23
 */
@RestController
@RequestMapping("/webSocketUserDialogue")
@Api(tags = "webSocket-聊天成员")
public class WebSocketUserDialogueController {
    @Autowired
    private WebSocketUserDialogueService webSocketUserDialogueService;

    /**
     * 老师查询自己的备课授课列表
     */
//    @PreAuthorize("@ss.hasPermi('platform:course:list')")
    @GetMapping("/list")
    @ApiOperation(value = "获取成员列表", notes = "分为0一对一 1群聊 2通告")
    public AjaxResult list(String message, Integer type) {
        return webSocketUserDialogueService.getUserList(message,type);
    }
    @PostMapping("/addGroupUser")
    @ApiOperation(value = "添加群聊", notes = "添加群聊")
    public AjaxResult addGroupUser(@RequestBody WebSocketUserDialogue webSocketUserDialogue) {
        return webSocketUserDialogueService.addGroupUser(webSocketUserDialogue);
    }

    @PostMapping("/updateGroupNotice")
    public AjaxResult updateGroupDetail(@RequestBody Map<String,Object> map) {
        return webSocketUserDialogueService.updateGroupDetail(map);
    }


    @PostMapping("/deleteGroupUser")
    @ApiOperation(value = "退出删除群聊/拉取好友进入群聊", notes = "退出删除群聊/拉取好友进入群聊,type 1退出删除群聊，2拉好友进入群聊，3群主解散")
    public AjaxResult deleteGroupUser(Integer dialogueId,String userName,Integer type) {
        return webSocketUserDialogueService.deleteGroupUser(dialogueId,userName,type);
    }

    @PostMapping("/deleteUser")
    @ApiOperation(value = "删除好友", notes = "删除以后对方也会删除")
    public AjaxResult deleteUser(Integer dialogueId) {
        return webSocketUserDialogueService.deleteUser(dialogueId);
    }



}

